// pages/dired/dired.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:"",
    type:'',
    num:'',
    img:"",
    wenid:"",
    uid:"",
    id:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    let that = this;
    that.setData({
      type:options.pin,
      wenid:options.wenid,
      uid:options.uid
    })
    console.log(options)
    app.request({
      url: '/selectNotewxUser',
      data:{
        wineid:that.data.wenid,
        uid:options.uid
      },
      method:'post',
      success: function (res) {
        
        console.log(res)
        res.data.selectNotewxUser.map((item, i) => {
          res.data.selectNotewxUser[i].labelEntry = item.labelEntry.split(',')
          res.data.selectNotewxUser[i].labelMiddle = item.labelMiddle.split(',')
          res.data.selectNotewxUser[i].labelSmell = item.labelSmell.split(',')
          res.data.selectNotewxUser[i].labelTaste = item.labelTaste.split(',')
        })
       
        that.setData({
          list: res.data.selectNotewxUser,
          img:res.data.noteUserVo,
          num: res.data.selectNotewxUser[0].score
        })
        console.log(that.data.img)
      }
    })
    // this.getdate(options.wenid)
  },
  del:function(e){
    console.log(e.currentTarget.dataset.item.id)
    let that = this;
    app.request({
      url: '/deleteNote',
      data:{
        wineid:e.currentTarget.dataset.item.wineid ,
        uid: e.currentTarget.dataset.item.uid,
        id:e.currentTarget.dataset.item.id,

      },
      method:'post',
      success: function (res) {
        if(res.code==200){
          wx.showToast({
            title: '删除成功',
            icon: 'succes',
            duration: 500,
            mask: true
          })
          wx.navigateTo({
            url: '../note/noteListSelf/noteListSelf',
          })
          app.request({
            url: '/note/user-note?wineid=' + that.data.wenid + '&uid=' + that.data.uid,
            success: function (res) {
             
              console.log(res)
              res.data.list.map((item, i) => {
                res.data.list[i].label_entry = item.label_entry.split(',')
                res.data.list[i].label_middle = item.label_middle.split(',')
                res.data.list[i].label_smell = item.label_smell.split(',')
                res.data.list[i].label_taste = item.label_taste.split(',')
              })

              that.setData({
                list: res.data.list,
                img: res.data.user,
                num: res.data.score_average
              })
              console.log(that.data.img)
            }
          })
        }
      }
    })
  },
getdate:function(wieid){
  
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})